import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFileChooser;
import javax.swing.JButton;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;

public class ScansioneDirectoryFrame extends JFrame {
	private final JButton btnApriDirectory = new JButton("Apri directory");
	private final JFileChooser fc = new JFileChooser();
	final static JPanel panel = new JPanel(); 

	public ScansioneDirectoryFrame() {
		
	
		setTitle("Scansiona directory");
		
        panel.setLayout(new BorderLayout(10, 10));
    	panel.setSize(496,211);
        JLabel label = new JLabel("Scegli la directory:");
        label.setFont(new Font("Georgia", Font.PLAIN, 14));
        label.setForeground(new Color(50, 50, 25));
        panel.add(label, BorderLayout.CENTER);
        panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        
        
        //panel.add(fc);
        
        getContentPane().add(panel);
        panel.add(btnApriDirectory, BorderLayout.SOUTH);
        
        btnApriDirectory.addMouseListener(new MouseAdapter() {
        	@Override
        	public void mouseClicked(MouseEvent arg0) {
        		System.out.println("Ecco la console dopo il click");
        		int returnVal = fc.showOpenDialog(panel);
        		 File file = fc.getSelectedFile();
        		 //fc.setVisible(true);
        		System.out.println(returnVal + " - " + file.getPath());
        	}
        });
        
        pack();
	}
	
	
}
